﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" lay-filter="config-form" style="padding: 15px 0 0 0;">
            <input type="hidden" name="Id" value="@Model.Id" />

            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">内容组名称</label>
                <div class="layui-input-block">
                    <input type="text" name="GroupName" lay-verify="required" placeholder="请输入内容组名称" autocomplete="off" class="layui-input" value="@Model.GroupName">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    内容组描述
                </label>
                <div class="layui-input-block">
                    <textarea name="Remark" placeholder="请输入内容组描述" class="layui-textarea">@Model.Remark</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-hide" lay-submit lay-filter="contentGroup-submit" id="contentGroup-submit">提交</button>
                </div>
            </div>
        </form>
    </div>
</div>


@section scripts{
    <script>
      
        layui.use([ 'form', 'lscom'], function () {
          
            let form = layui.form;
            let $ = layui.jquery;
     
            let lscom = layui.lscom;

            var index = parent.layer.getFrameIndex(window.name);

            window.submitForm = function () {
                $("#contentGroup-submit").click();
            }
           
            form.on('submit(contentGroup-submit)', function (data) {

                var field = data.field;
                var waitIndex = parent.layer.load(2);
                lscom.ajax({
                    url: "/Cms/ContentGroup/SaveData",
                    data: JSON.stringify(field),
                    lsHandleError: false
                }).done(function (data) {
                    if (data.code == 0) {
                        data.index = index;
                        let parentWindow = parent.selectedWindow().window;
                        parentWindow.saveCallback(data);
                    }
                }).fail(function (message) {
                    lscom.notify.error(message);
                }).always(function () {
                    parent.layer.close(waitIndex);
                });

                return false;
            });
        });
    </script>
   
}

